package com.quan.weixin.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.quan.common.core.BaseService;
import com.quan.weixin.entity.WeixinArticleGroupArticle;
import com.quan.weixin.mapper.WeixinArticleGroupArticleMapper;
import com.quan.weixin.service.WeixinArticleGroupArticleService;

import tk.mybatis.mapper.entity.Condition;

@Service
public class WeixinArticleGroupArticleServiceImpl extends BaseService<WeixinArticleGroupArticle> implements WeixinArticleGroupArticleService {
	
	@Autowired
	private WeixinArticleGroupArticleMapper mapper ;

	@Override
	public void deleteByGroupId(Integer groupId) {
		Condition condition = new Condition(WeixinArticleGroupArticle.class) ;
		condition.createCriteria().andEqualTo("articleGroupId", groupId);
		this.mapper.deleteByCondition(condition) ;
	}

	@Override
	public int getArticleCount(Integer groupId) {
		Condition condition = new Condition(WeixinArticleGroupArticle.class) ;
		condition.createCriteria().andEqualTo("articleGroupId", groupId);
		return this.mapper.selectCountByCondition(condition);
	}

	@Override
	public List<WeixinArticleGroupArticle> selectByGroupId(Integer groupId) {
		return this.mapper.selectByGroupId(groupId);
	}

	@Override
	public Integer selectCountArticleIdByGroupId(Integer groupId,
			Integer articleId) {
		Condition condition = new Condition(WeixinArticleGroupArticle.class) ;
		condition.createCriteria().andEqualTo("articleGroupId", groupId).andEqualTo("articleId", articleId);
		return this.mapper.selectCountByCondition(condition);
	}
	

}
